﻿<div ms-controller="ZYGLLIST">

    <div class="jg-left pull-left ft14" style=" padding: 0px 5px;">
        <ul class="jg-list-box" ms-repeat-el="LBTypeData">
            <li>
                <div class="jg-item">
                    <b>
                        <i class="caret active"></i>
                        <span class="jg-name">{{el.name}}</span>
                    </b>
                    <div class="jg-sz">
                    </div>
                </div>
                <ul class="children-list" style="display: block;">
                    <li ms-repeat-item="el.kcflitem" ms-click="SelectType(item.id,el)">
                        <div class="jg-item chitype" ms-attr-dataid="item.id">
                            <b>
                                <i class="caret "></i>
                                <span class="jg-name">{{item.name}}</span>
                            </b>
                            <div class="jg-sz">

                            </div>
                        </div>
                        <ul class="children-list"></ul>
                    </li>

                </ul>
            </li>
        </ul>

    </div>


    <div class="jg-right " style="min-height:600px">

        <div class="btn-add" ms-if="isgl=='0'">
            <button type="button" class="btn btn-info btn-lg" id="addFile"><i class="iconfont icon-jiahao ft12 mr5"></i>添加资源</button>
        </div>
        <div class="jg-cont ft14">

            <div class=" ml15" style="position: relative">
                <a class="c-default dropdown-toggle ft16" data-toggle="dropdown">
                    <i class="iconfont icon-bookmark c-default mr5"></i>知识库
                </a>
               
            </div>
            
        </div>
        <!-- 按条件选择 -->
        <div class="tab-filter-type">

            <!-- 搜索 -->
            <div class="oh mt10">
                <div class="input-group ml15" style="width:295px;">
                    <input type="search" class="form-control" ms-duplex="search.searchcontent" placeholder=" ">
                    <span class="input-group-addon" ms-click="GetLIST()">搜索</span>
                </div>
            </div>
        </div>

        <!-- 表格 -->
        <div class="default-tab ft14 hover-btn" style="    margin-top: 60px;">
            
            <table class="table table-striped table-responsive table-hover">
                <thead>
                    <tr>
                        <th class="tc">
                            序号
                        </th>
                        <th>名称</th>
                        <th>类型</th>

                        <th>大小</th>
                        <th style="width:150px;">操作</th>

                    </tr>
                </thead>
                <tbody>
                    <tr ms-repeat-el="tmpListData">
                        <td class=" tc">
                            {{$index+1+page.pagecount*(page.pageindex-1)}}
                        </td>
                        <td class="lk">{{el.Name}}</td>
                        <td>{{el.FileExtendName}}</td>

                        <td>{{el.FileSize}}</td>
                        <td>
                            <span>
                                <a class="cz-btn ft18 bj-color tip" ms-click="yl(el)" title="预览">
                                    <i class="iconfont icon-gjjl"></i>
                                </a>
                                <a class="cz-btn ft18 bj-color tip" ms-click="updatekc(el)" title="编辑">
                                    <i class="iconfont icon-bianji"></i>
                                </a>
                                <a class="cz-btn ft18 sc-color tip" data-toggle="tooltip" ms-attr-title="删除" ms-click="DEL(el,$event)">
                                    <i class="iconfont icon-shanchu"></i>
                                </a>
                            </span>
                        </td>
                    </tr>

                </tbody>
                <tfoot>
                    <tr ms-if="isnull"><td class="tc"></td><td>暂无数据</td></tr>
                </tfoot>
            </table>
            <div class="ui-datatable-page ft14 pl20 hidden">

                <div id="pageDiv" ms-visible="model.page.total>model.pageNum[0].num" class="pull-right"></div>
                <div class="pull-right" ms-visible="tmpListData.size()!=0">
                    <span>共{{model.page.total}}条记录</span>
                    <span ms-visible="model.page.total>model.pageNum[0].num">
                        选择每页条数
                        <select style="height: 25px; width: 50px;" ms-change="selNum(this.value)" ms-duplex="model.page.pagecount">
                            <option ms-repeat-pg="pageNum" ms-attr-value="pg.num" ms-attr-selected="pg.num==model.page.pagecount?'selected':''">{{pg.num}}</option>
                        </select>
                    </span>
                </div>

            </div>
        </div>
        <div class="modal fade" id="ADDZY" role="dialog">
            <div class="modal-dialog" role="document" style="width: 500px">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">修改资源属性</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-horizontal">
                            <div class="form-group">
                                <label class="col-xs-4 control-label"><span class="Required " style="color:red">*</span>资源名称</label>
                                <input type="text" class="form-control szhl_require" style="width: 200px" placeholder="请输入资源名称" id="zyname" />
                            </div>
                            <!--<div class="form-group">
                            <label class="col-xs-4 control-label">是否公开</label>
                            <select class="form-control szhl_require" id="isgk" style="width: 200px">
                                <option value="1" selected="selected">是</option>
                                <option value="2">否</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-4 control-label"><span class="Required " style="color:red">*</span>资源时长</label>
                            <input type="text" class="form-control szhl_require" style="width: 200px" placeholder="请输入资源时长" id="zysc" />
                        </div>-->
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-success" id="conaddForder" ms-click="SaveZY()">确&nbsp;&nbsp;认</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>

    var tempindex = avalon.define({
        $id: "ZYGLLIST",
        tmpListData: [],
        LBTypeData: [],
        slefolid: "",
        slefolname: "",
        isgl:"1",
        covimg: function (zyid) {
            return ComFunJS.getCookie("fileapi") + "/document/YL/" + zyid + "/1";
        },
        SelectType: function (type,el) {
            tempindex.slefolid = type;
            tempindex.GetLIST();
        },

        selitem: {},
        yl: function (el) {
            if ($.inArray(el.FileExtendName, ['doc', 'docx', 'ppt', 'pptx', 'pdf']) > -1) {
                var url = ComFunJS.getfileapi() + "/document/YL/" + el.zyid;
                window.open(url);
            }
        },
        inittype: function () {
            $(".chitype").eq(0).addClass("active");
            if ($(".chitype").length > 0) {
                var dataid = $(".chitype").eq(0).attr("dataid");
                tempindex.SelectType(dataid);
            }
        },
        selNum: function (item) {    //选择显示的条数
            model.page.pagecount = item;
            tempindex.GetLIST();
        },
        InitWigetData: function (data) {
            tempindex.isgl = data;
            model.search.seartype = '1';
            //显示的列名
            model.ShowColumns.clear();
            $.getJSON('/api/Bll/ExeAction?Action=QYWD_GETZYFLJSON', {}, function (resultData) {
                if (resultData.ErrorMsg == "" && resultData.Result.length > 0) {
                    tempindex.LBTypeData = resultData.Result;
                    setTimeout("tempindex.inittype()",1000)
                }
            })
            ComFunJS.loadJs(ComFunJS.getfileapi() + "/Web/qj_upload.js", function () {
                var obj = {
                    uploadButtton: 'addFile',
                    fileapiurl: ComFunJS.getfileapi(),
                    usercode: "qycode",
                    secret: "qycode",
                    upinfo: "上传资源",
                    webupconfig: {
                        fileNumLimit: 5,
                        accept: {
                            title: '多媒体',
                            extensions: 'doc,docx,ppt,pptx,pdf,mp4'
                        }
                    },
                    filecomplete: function (fileData) {
                    },
                    closeupwin: function (fileData) {
                        alert(JSON.stringify(fileData))
                        $.getJSON("api/Bll/ExeAction?Action=QYWD_ZYADD", { P1: fileData, P2: tempindex.slefolid }, function (jsonresult) {
                            if ($.trim(jsonresult.ErrorMsg) == "") {
                                ComFunJS.winsuccess("操作成功");
                                tempindex.GetLIST();
                            }
                        });
                    }
                };
                var upload = new QJUpload(obj);
            })
        },
        updatekc: function (item) {
            tempindex.selitem = item;
            $("#zyname").val(item.title);
            $("#zysc").val(item.timeline);
            $("#ADDZY").modal('show');
        },

        SaveZY: function () {
            if (!$("#zyname").val()) {
                ComFunJS.winwarning("请输入资源名称");
                return;
            }

            $.getJSON("api/Bll/ExeAction?Action=QYWD_UPDZY", { P1: $("#zyname").val(), ZYID: tempindex.selitem.ID }, function (jsonresult) {
                if ($.trim(jsonresult.ErrorMsg) == "") {
                    tempindex.GetLIST();
                    ComFunJS.winsuccess("操作成功");
                    $('#ADDZY').modal('hide');
                }
            });
        },
        delfol: function (item, event) {
            if (event.stopPropagation) {
                event.stopPropagation();
            }
            top.ComFunJS.winconfirm("确定删除此记录吗？", function () {
                $.getJSON('api/Bll/ExeAction?Action=QYWD_DELFILE', { P1: item.ID }, function (result) {
                    if ($.trim(result.ErrorMsg) == "") {

                        tempindex.tmpListData.remove(item);
                        top.ComFunJS.winsuccess("删除成功");
                    }
                })
            })
        },
        GetLIST: function () {
            model.page.pageindex = 1;
            tempindex.tmpListData.clear();
            $.getJSON('/api/Bll/ExeAction?Action=QYWD_GETZYGLLIST', { p: 1, type: tempindex.slefolid, P1: model.search.searchcontent, pagecount: model.page.pagecount }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    tempindex.tmpListData = resultData.Result;
                    if (tempindex.tmpListData.size() == 0) { model.isnull = true; } else { model.isnull = false; }
                    model.page.total = resultData.Result1;
                    laypage({
                        cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                        pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / model.page.pagecount), //通过后台拿到的总页数
                        curr: 1, //初始化当前页
                        skin: 'molv',
                        jump: function (e) { //触发分页后的回调
                            if (e.curr != model.page.pageindex) {
                                $.getJSON('/api/Bll/ExeAction?Action=QYWD_GETZYGLLIST', { p: e.curr, type: tempindex.slefolid, P1: model.search.searchcontent, pagecount: model.page.pagecount }, function (resultData) {
                                    if (resultData.ErrorMsg == "") {
                                        tempindex.tmpListData = resultData.Result;
                                    }
                                })
                                model.page.pageindex = e.curr;
                            }
                        }
                    });
                }
            })
        }
    })//@ sourceURL=APP_knoindex.js;
</script>
